
<?php
 public function     modifierType($type, &$user, $request)
    {
        switch ($type)
        {
            case 'e' :
                $this->creerEtudiant($user, $request, $type);
                break;
            case 't' :
                $user->setRoles(array('ROLE_USER', 'ROLE_TUTEUR'))
                    ->setType($type);
                break;
            case 's' :
                $user->setRoles(array('ROLE_USER', 'ROLE_TUTEUR', 'ROLE_SECRETAIRE'))
                    ->setType($type);
                break;
            default :
                $user->setType($type);
        }
    }

    public function     creerEtudiant(&$user, $request, $type)
    {
        $em = $this->container->get('doctrine.orm.default_entity_manager');
        $etudiant = new Etudiant();

        $etudiant->setNumEtud($request->get('numEtud'));
        $etudiant->setUe($em->getRepository('SiteGeneralBundle:Ue')->findOneById($request->get('ue')));

        $user->setEtudiant($etudiant);
        $user->setType($type);
    }
}
?>
